import { type pageInfo } from '@/page/types/base/baseRequestPage'

export interface cityInfo {
  /**
   * 子id
   */
  id: string
  /**
   * 父id
   */
  pid: string | null
  children: cityInfo[]
  /** 名称 */
  name: string
  /** 代码 */
  code: string
  createTime: string
}

export interface relationTreeInfo {
  id: string | null
  pid: string | null
  name: string
  children: relationTreeInfo[]
}

export interface cityS extends pageInfo {
  name: string
  code: string
}

export class cityClass {
  cityDialog = false
  citytable = [] as cityInfo[]
  page = 0
  size = 10
  total = 0
  cityS: cityS = {
    name: '',
    code: '',
    page: 1,
    size: 10,
    total: 0
  }

  editCity: cityInfo = {
    id: 0,
    pid: null,
    children: [] as cityInfo[],
    /** 名称 */
    name: '',
    /** 代码 */
    code: '',
    createTime: ''
  }

  rules = {
    code: [
      {
        required: true,
        message: '城市代码不能为空',
        trigger: 'blur'
      }
    ],
    name: [
      {
        required: true,
        message: '城市名称不能为空',
        trigger: 'blur'
      }
    ]
  }

  relationTreeData: relationTreeInfo = {
    id: null,
    pid: null,
    name: '',
    children: []
  }

  relationTrees = [] as relationTreeInfo[]
  props = {
    label: 'name',
    value: 'id',
    children: 'children',
    checkStrictly: true,
    emitPath: false
  }
}
